Skip to content

macOS native parity + GPU tone curve shader fix#8

Merged
myyc merged 1 commit intomasterfrom
followup/macos-parity-and-tone-curve-test
Apr 15, 2026
Merged

macOS native parity + GPU tone curve shader fix#8
myyc merged 1 commit intomasterfrom
followup/macos-parity-and-tone-curve-test

Conversation

@myyc
Copy link
Copy Markdown
Owner

@myyc myyc commented Apr 15, 2026

macOS parity

Convert the macOS raw processor to the wrapper pattern (same as Linux), which was the last standalone drift point after the Linux cleanup branch. Before: macos/raw_processor/raw_processor.c was a 250-line standalone copy ~60 lines out of sync with canonical. Most importantly it lacked raw_processor_set_highlight_mode, so any macOS build after the Linux refactor would crash at image load when the Dart FFI looked up the missing symbol.

  • Add macos/raw_processor/raw_processor_wrapper.c (one-liner that #includes ../../lib/ffi/raw/raw_processor_common.c).
  • Delete macos/raw_processor/raw_processor.{c,h}.
  • Update macos/build.sh and macos/Makefile to compile the wrapper and pass -I../lib/ffi/raw for the canonical header.
  • Update Xcode project input-paths so the "Build Native Libraries" phase re-runs on wrapper/canonical changes.
  • Update CLAUDE.md — macOS no longer needs special mirroring.

GPU tone curve fixes

Audit of ROADMAP's "GPU tone curve pending" claim: the shader code is all there, but there were two real bugs that a CPU↔GPU comparison test would have caught:

  1. Operation order was reversed from CPU. The shader applied master RGB curve first then per-channel curves; CPU does per-channel first. Non-commutative for non-identity curves — outputs differed by several LSBs.
  2. Float→int truncation when indexing the byte LUT: sRGB 0.50196 (byte 128) got truncated to index 127 instead of rounded to 128. Off by one at every quantisation boundary.

Both fixed in linux/vulkan_processor/shaders/image_process.comp. Added a CPU↔GPU comparison test with an S-curve + distinct per-channel curves; CPU and GPU now agree to within 1 LSB (measured: maxDiff 0, avgDiff 0.00 on the full test fixture).

Tests

31 native tests pass (was 30), 66 unit tests pass, dart analyze clean.

## macOS parity
Convert the macOS raw processor to the wrapper pattern (same as Linux),
which was the last standalone drift point after the Linux cleanup branch.
Before: `macos/raw_processor/raw_processor.c` was a 250-line standalone
copy ~60 lines out of sync with canonical. Most importantly it lacked
`raw_processor_set_highlight_mode`, so any macOS build after the Linux
refactor would crash at image load when the Dart FFI looked up the
missing symbol.

- Add `macos/raw_processor/raw_processor_wrapper.c` (one-liner that
  `#include`s `../../lib/ffi/raw/raw_processor_common.c`).
- Delete `macos/raw_processor/raw_processor.{c,h}`.
- Update `macos/build.sh` and `macos/Makefile` to compile the wrapper
  and pass `-I../lib/ffi/raw` for the canonical header.
- Update Xcode project input-paths so the "Build Native Libraries" phase
  re-runs on wrapper/canonical changes.
- Update `CLAUDE.md` — macOS no longer needs special mirroring.

## GPU tone curve fixes
Audit of ROADMAP's "GPU tone curve pending" claim: the shader code is
all there, but there were two real bugs that a CPU↔GPU comparison test
would have caught:

1. **Operation order was reversed** from CPU. The shader applied
   master RGB curve first then per-channel curves; CPU does per-channel
   first. Non-commutative for non-identity curves — outputs differed
   by several LSBs.
2. **Float→int truncation** when indexing the byte LUT: sRGB 0.50196
   (byte 128) got truncated to index 127 instead of rounded to 128. Off
   by one at every quantisation boundary.

Both fixed in `linux/vulkan_processor/shaders/image_process.comp`.
Added a CPU↔GPU comparison test with an S-curve + distinct per-channel
curves; CPU and GPU now agree to within 1 LSB (measured: maxDiff 0,
avgDiff 0.00 on the full test fixture).

## Tests
31 native tests pass (was 30), 66 unit tests pass, `dart analyze` clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@myyc myyc merged commit 7297d04 into master Apr 15, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant